﻿<?php

    include('db_config.php');
    
	$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
	mysql_select_db($dbname);
	$return_arr = array();
			
	if ($conn)
	{		
		$fetch = mysql_query("SELECT * FROM vnf_category where admin_title like '%" . mysql_real_escape_string($_GET['q']) . "%'");
		/* Retrieve and store in array the results of the query.*/
		while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
			$row_array['category_id'] = $row['category_id'];
			$row_array['admin_title'] = $row['admin_title'];			
			$cname = $row["admin_title"];
			$cid   = $row["category_id"];
			//array_push($return_arr,$row_array);
			echo "$cname|$cid\n";
		}
	}
	/* Free connection resources. */
	mysql_close($conn);
	/* Toss back results as json encoded array. */

	//echo json_encode($return_arr);
?>